home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp-print.idb / usr / freeware / info / gimpprint.info-2.z / gimpprint.info-2
Text File  |  2002-10-07  |  48KB  |  1,081 lines

  1. This is gimpprint.info, produced by makeinfo version 4.0 from
  2. gimpprint.texi.
  3.  
  4. INFO-DIR-SECTION Libraries
  5. START-INFO-DIR-ENTRY
  6. * GIMP-Print: (gimpprint).      print plugin for the GIMP, and printing library
  7. END-INFO-DIR-ENTRY
  8.  
  9.    This file documents the gimpprint library and associated programs
  10. used for high quality printing.
  11.  
  12.    Copyright (C) 2001 Michael Sweet (<mike@easysw.com>) and Robert
  13. Krawitz (<rlk@alum.mit.edu>)
  14.  
  15.    Permission is granted to make and distribute verbatim copies of this
  16. manual provided the copyright notice and this permission notice are
  17. preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided that
  21. the entire resulting derived work is distributed under the terms of a
  22. permission notice identical to this one.
  23.  
  24.    Permission is granted to copy and distribute translations of this
  25. manual into another language, under the above conditions for modified
  26. versions, except that this permission notice may be stated in a
  27. translation approved by the Foundation.
  28.  
  29. 
  30. File: gimpprint.info,  Node: Options functions,  Next: Paper functions,  Prev: Dither functions,  Up: Functions
  31.  
  32. Options functions
  33. =================
  34.  
  35.  - Data type: void * stp_option_t
  36.      This is an opaque data type, whose structure is not visible to the
  37.      user.
  38.  
  39.  - Function: void stp_set_option(stp_vars_t V, const char *NAME, const
  40.           char *DATA, int BYTES)
  41.  
  42.  - Function: void stp_clear_option (stp_vars_t V, const char *NAME)
  43.  
  44.  - Function: void stp_clear_all_options (stp_vars_t V)
  45.  
  46.  - Function: size_t stp_option_count (const stp_vars_t V)
  47.  
  48.  - Function: const stp_option_t stp_get_option_by_index (const
  49.           stp_vars_t V, size_t IDX)
  50.  
  51.  - Function: const stp_option_t stp_get_option_by_name (const
  52.           stp_vars_t V, const char *NAME)
  53.  
  54.  - Function: const char * stp_option_data (const stp_option_t OPTION)
  55.      *Note*: not null delimited!
  56.  
  57.  - Function: const char * stp_option_name (const stp_option_t OPTION)
  58.  
  59.  - Function: size_t stp_option_length (const stp_option_t OPTION)
  60.  
  61. 
  62. File: gimpprint.info,  Node: Paper functions,  Next: Printer functions,  Prev: Options functions,  Up: Functions
  63.  
  64. Paper functions
  65. ===============
  66.  
  67.  - Data type: void * stp_papersize_t
  68.      This is an opaque data type, whose structure is not visible to the
  69.      user.
  70.  
  71.  - Data type:  stp_papersize_unit_t
  72.           typedef enum papersize_unit
  73.           {
  74.             PAPERSIZE_ENGLISH,
  75.             PAPERSIZE_METRIC
  76.           } stp_papersize_unit_t;
  77.  
  78.  - Function: int stp_known_papersizes (void)
  79.  
  80.  - Function: const stp_papersize_t stp_get_papersize_by_name (const
  81.           char *NAME)
  82.  
  83.  - Function: const stp_papersize_t stp_get_papersize_by_size (int L,
  84.           int W)
  85.  
  86.  - Function: const stp_papersize_t stp_get_papersize_by_index (int
  87.           INDEX)
  88.  
  89.  - Function: const char * stp_papersize_get_name (const stp_papersize_t
  90.           PT)
  91.  
  92.  - Function: unsigned stp_papersize_get_width (const stp_papersize_t PT)
  93.  
  94.  - Function: unsigned stp_papersize_get_height (const stp_papersize_t
  95.           PT)
  96.  
  97.  - Function: unsigned stp_papersize_get_top (const stp_papersize_t PT)
  98.  
  99.  - Function: unsigned stp_papersize_get_left (const stp_papersize_t PT)
  100.  
  101.  - Function: unsigned stp_papersize_get_bottom (const stp_papersize_t
  102.           PT)
  103.  
  104.  - Function: unsigned stp_papersize_get_right (const stp_papersize_t PT)
  105.  
  106.  - Function: stp_papersize_unit_t stp_papersize_get_unit (const
  107.           stp_papersize_t PT)
  108.  
  109. 
  110. File: gimpprint.info,  Node: Printer functions,  Next: Settings functions,  Prev: Paper functions,  Up: Functions
  111.  
  112. Printer functions
  113. =================
  114.  
  115.  - Data type: void * stp_printer_t
  116.      This is an opaque data type, whose structure is not visible to the
  117.      user.
  118.  
  119.  - Function: int stp_known_printers (void)
  120.  
  121.  - Function: const stp_printer_t stp_get_printer_by_index (int IDX)
  122.  
  123.  - Function: const char * stp_printer_get_long_name (const
  124.           stp_printer_t P)
  125.  
  126.  - Function: const stp_printer_t stp_get_printer_by_long_name (const
  127.           char *LONG_NAME)
  128.  
  129.  - Function: const stp_printer_t stp_get_printer_by_driver (const char
  130.           *DRIVER)
  131.  
  132.  - Function: int stp_get_printer_index_by_driver (const char *DRIVER)
  133.  
  134.  - Function: const char * stp_printer_get_driver (const stp_printer_t P)
  135.  
  136.  - Function: int stp_printer_get_model (const stp_printer_t P)
  137.  
  138.  - Function: const stp_printfuncs_t * stp_printer_get_printfuncs (const
  139.           stp_printer_t P)
  140.  
  141.  - Data type:  stp_printfuncs_t
  142.           typedef struct
  143.           {
  144.             char  **(*parameters)(const stp_printer_t printer,
  145.                                   const char *ppd_file,
  146.                                   const char *name, int *count);
  147.             void  (*media_size)(const stp_printer_t printer,
  148.                                 const stp_vars_t v, int *width,
  149.                                 int *height);
  150.             void  (*imageable_area)(const stp_printer_t printer,
  151.                                     const stp_vars_t v,
  152.                                     int *left, int *right,
  153.                                     int *bottom, int *top);
  154.             void  (*limit)(const stp_printer_t printer,
  155.                            const stp_vars_t v,
  156.                            int *width, int *height);
  157.             void  (*print)(const stp_printer_t printer,
  158.                            stp_image_t *image, const stp_vars_t v);
  159.             const char *(*default_parameters)(const stp_printer_t printer,
  160.                                               const char *ppd_file,
  161.                                               const char *name);
  162.             void  (*describe_resolution)(const stp_printer_t printer,
  163.                                          const char *resolution,
  164.                                          int *x, int *y);
  165.             int   (*verify)(const stp_printer_t p, const stp_vars_t v);
  166.           } stp_printfuncs_t;
  167.  
  168.  - Data type:  stp_image_t
  169.           typedef struct stp_image
  170.           {
  171.             void (*init)(struct stp_image *image);
  172.             void (*reset)(struct stp_image *image);
  173.             void (*transpose)(struct stp_image *image);
  174.             void (*hflip)(struct stp_image *image);
  175.             void (*vflip)(struct stp_image *image);
  176.             void (*crop)(struct stp_image *image,
  177.                          int left, int top, int right,
  178.                          int bottom);
  179.             void (*rotate_ccw)(struct stp_image *image);
  180.             void (*rotate_cw)(struct stp_image *image);
  181.             void (*rotate_180)(struct stp_image *image);
  182.             int  (*bpp)(struct stp_image *image);
  183.             int  (*width)(struct stp_image *image);
  184.             int  (*height)(struct stp_image *image);
  185.             void (*get_row)(struct stp_image *image,
  186.                   unsigned char *data, int row);
  187.             const char *(*get_appname)(struct stp_image *image);
  188.             void (*progress_init)(struct stp_image *image);
  189.             void (*note_progress)(struct stp_image *image,
  190.                   double current, double total);
  191.             void (*progress_conclude)(struct stp_image *image);
  192.             void *rep;
  193.           } stp_image_t;
  194.      This is an abstract data type for interfacing with the program
  195.      which created the image.
  196.  
  197.  - Function: const stp_vars_t stp_printer_get_printvars (const
  198.           stp_printer_t P)
  199.  
  200. 
  201. File: gimpprint.info,  Node: Settings functions,  Next: Version functions,  Prev: Printer functions,  Up: Functions
  202.  
  203. Settings functions
  204. ==================
  205.  
  206.  - Function: stp_convert_t stp_choose_colorfunc (int OUTPUT_TYPE, int
  207.           IMAGE_BPP, const unsigned char *CMAP, int *OUT_BPP, const
  208.           stp_vars_t V)
  209.  
  210.  - Function: void stp_compute_page_parameters (int PAGE_RIGHT, int
  211.           PAGE_LEFT, int PAGE_TOP, int PAGE_BOTTOM, double SCALING, int
  212.           IMAGE_WIDTH, int IMAGE_HEIGHT, stp_image_t *IMAGE, int
  213.           *ORIENTATION, int *page_width, int *PAGE_HEIGHT, int
  214.           *OUT_WIDTH, int *OUT_HEIGHT, int *LEFT, int *TOP)
  215.  
  216.  - Function: const stp_vars_t stp_default_settings (void)
  217.  
  218.  - Function: const stp_vars_t stp_maximum_settings (void)
  219.  
  220.  - Function: const stp_vars_t stp_minimum_settings (void)
  221.  
  222. 
  223. File: gimpprint.info,  Node: Version functions,  Prev: Settings functions,  Up: Functions
  224.  
  225. Version functions
  226. =================
  227.  
  228.  - Function: const char * stp_check_version (unsigned int
  229.           REQUIRED_MAJOR,
  230.      unsigned int REQUIRED_MINOR, unsigned int REQUIRED_MICRO)
  231.  
  232.      This function checks whether the version of libgimpprint that the
  233.      program is linked with is equal to the version number passed to
  234.      it. If the version is the same, the function returns `NULL'. If
  235.      any of the version numbers do not match (i.e. the library version
  236.      is too old or too new), a string containing a desription of the
  237.      difference is returned. The first error found is returned. The
  238.      function checks in the order major, minor, micro.
  239.  
  240. Version macros
  241. --------------
  242.  
  243.  - Macro: GIMPPRINT_CHECK_VERSION (major,minor,micro)
  244.      This macro returns zero if the version of the libgimpprint headers
  245.      are greater or equal to the version given as an argument. It
  246.      returns nonzero if the version of the libgimpprint headers are
  247.      less than the argument.
  248.  
  249.  - Macro: GIMPPRINT_MAJOR_VERSION
  250.  
  251.  - Macro: GIMPPRINT_MINOR_VERSION
  252.  
  253.  - Macro: GIMPPRINT_MICRO_VERSION
  254.  
  255.  - Macro: GIMPPRINT_CURRENT_INTERFACE
  256.  
  257.  - Macro: GIMPPRINT_BINARY_AGE
  258.  
  259.  - Macro: GIMPPRINT_INTERFACE_AGE
  260.  
  261.    These macros are integers holding the version numbers. They should be
  262. used for compile-time checking only. To check version numbers at
  263. run-time, use the equivalent variables. Note that at present (4.1.x
  264. development branch) the library interface version numbers are not used.
  265.  
  266. Version variables
  267. -----------------
  268.  
  269.  - Variable: const unsigned int gimpprint_major_version
  270.  
  271.  - Variable: const unsigned int gimpprint_minor_version
  272.  
  273.  - Variable: const unsigned int gimpprint_micro_version
  274.  
  275.  - Variable: const unsigned int gimpprint_current_interface
  276.  
  277.  - Variable: const unsigned int gimpprint_binary_age
  278.  
  279.  - Variable: const unsigned int gimpprint_interface_age
  280.  
  281.    These variables hold the library version numbers. Because the
  282. version of the library may change on a system using shared libraries,
  283. these should be used instead of the equivalent macros when checking the
  284. library version at run-time. Note that library interface version
  285. numbers are not used in the development branch, but are in the stable
  286. branch.
  287.  
  288. 
  289. File: gimpprint.info,  Node: Programs,  Next: Problems,  Prev: Functions,  Up: Top
  290.  
  291. Programs
  292. ********
  293.  
  294.    This chapter of the manual describes the use of some of the programs
  295. which use the GIMP-Print library (libgimpprint).  Note that there is now
  296. a user manual in DocBook/SGML format, currently provided in HTML,
  297. PostScript and PDF formats which is distributed with GIMP-Print.  This
  298. manual currently covers the use of the GIMP Print plugin and CUPS
  299. drivers.
  300.  
  301. * Menu:
  302.  
  303. * The GIMP plugin::             The print plugin for the GIMP
  304. * Ghostscript::                 Printer driver
  305. * CUPS::                        Printer driver
  306.  
  307. 
  308. File: gimpprint.info,  Node: The GIMP plugin,  Next: Ghostscript,  Prev: Programs,  Up: Programs
  309.  
  310. The GIMP Print plugin
  311. =====================
  312.  
  313.    The GIMP Print plugin is the printing facility for the GNU Image
  314. Manipulation Program(1).  This section examines the features offered by
  315. the Print plugin.
  316.  
  317.    The main window is divided into five panes:
  318.  
  319. Preview
  320. -------
  321.  
  322.    The Preview pane contains a positioning widget that allows
  323. interactively positioning the output on the page.  It contains an outer
  324. border, representing the sheet of paper; an inner border, representing
  325. the printable area of the printer; an arrow, pointing to the top of the
  326. page (the end that's fed into the printer); and a black rectangle,
  327. representing the position of the image on the page.  The image can be
  328. moved around on the paper.  When the first (left) button is used, the
  329. image is moved in screen pixels; when any other button is used, the
  330. image is moved in points(2).  The arrow resizes depending upon the
  331. media size chosen; the shaft of the arrow is always equal to one inch
  332. on the output.
  333.  
  334. [Figure not available in Info format]
  335.  
  336. Printer Settings
  337. ----------------
  338.  
  339.    The Printer Settings pane contains a dropdown menu for selecting a
  340. printer to print to.  There is a special `printer' named `File' that
  341. allows you to choose a file to print to, rather than a printer queue.
  342. The Setup box to the right allows specification of a printer type, a
  343. PPD file(3), and the command to be used to print.  Each distinct
  344. printer in the Printer list can have different settings applied to it.
  345. Below that is a combo box allowing choice of media size.  The choices
  346. are constrained to those that the printer supports.  Below that are
  347. dropdown menus for choosing media type (what kind of paper), media
  348. source (what input tray), ink type, and resolution.  All of these
  349. settings are printer-specific.
  350.  
  351. [Figure not available in Info format]
  352.  
  353. Position
  354. --------
  355.  
  356.    The Position pane contains various widgets to place the image on the
  357. paper.  These widgets work in conjunction with the Preview pane.  At the
  358. top of the pane is a button to center the image on the paper (not on the
  359. printable area), and on either side buttons to center vertically and
  360. horizontally.  Below these are four boxes that allow entry of the left,
  361. top, right, and bottom of the image.  These positions are relative to
  362. the top left of the paper(4).  There are two additional boxes that
  363. allow specification of the right margin and bottom margin if you
  364. prefer; these are relative to the bottom right corner of the paper.
  365. Any of these may have values entered into them; the preview image will
  366. be moved appropriately.
  367.  
  368.    *Note*: These entries do not resize the image.
  369.  
  370.    Finally, there is a pick box for orientation (landscape or portrait).
  371. There is an `Auto' mode that picks the orientation that yields the
  372. orientation that best matches that of the image to be printed.
  373.  
  374. Scaling
  375. -------
  376.  
  377.    The Scaling pane contains a slider that allows scaling of the image.
  378. The image can be scaled in either percent of the printable area (*not*
  379. the page in this case) or pixels per inch (PPI) via a radio button
  380. below the slider.  PPI allows matching image resolution to printer
  381. resolution.  The image may be scaled using either method to between 5
  382. and 100% of the imageable area.  It is not possible to crop with the
  383. Print plugin.  In Percent mode, the image is scaled so that neither
  384. axis will be longer than the percent of the printable area specified.
  385. For example, if you print an image at 20%, it will be possible to tile
  386. the image 5 times on one axis and at least 5 times on the other.  To
  387. the right of the radio button is a button called Set Image Scale.  This
  388. sets the scaling to PPI, and sets the resolution as closely as possible
  389. to the resolution stored in the image.  To the right of the Set Image
  390. Scale button are two boxes that allow entry of width and height of the
  391. image.  These set the scaling mode to PPI.  Specifying one
  392. automatically sets the other, and the image is repositioned as needed
  393. to prevent it from falling off the edge of the page.
  394.  
  395.    To its right is a button group that allows choosing English (inch)
  396. units or metric (centimeter) units.
  397.  
  398. Image Settings
  399. --------------
  400.  
  401.    The Image Settings pane allows choice of Line Art, Solid Colors, or
  402. Photograph image type.  Line art or Solid Colors should be used for
  403. graphics containing mostly solid areas of color.  They're very similar
  404. to each other.  Photograph mode dithers more slowly, but produces more
  405. accurate colors.  To the right of these three radio buttons is a button
  406. called Adjust Color.  This pops up a new window that controls various
  407. output quality settings.  That will be described separately.  Finally,
  408. there is a choice of Black and White, Color and Monochrome output.
  409. Monochrome output can be used to print absolute black and white very
  410. quickly.
  411.  
  412. Adjust Output
  413. .............
  414.  
  415.    The Adjust Output button button pops up a non-modal dialog that
  416. allows adjustment of various parameters related to the print quality.
  417. These are independent of the controls within the GIMP itself and only
  418. affect the print.
  419.  
  420. [Figure not available in Info format]
  421.  
  422.    At the top of the window is a thumbnail of the image that changes to
  423. reflect the color settings of the image.  This enables you to get an
  424. idea of how the image will print out as you adjust settings.
  425.  
  426.    Below that there are eight sliders:
  427.  
  428. _Brightness_
  429.      (0-2.0, default 1.0) Adjust the brightness of the image.
  430.  
  431. _Contrast_
  432.      (0-4.0, default 1.0) Adjust the output contrast.
  433.  
  434. _Cyan, Magenta, Yellow_
  435.      (0-4.0, default 1.0) Adjust the cyan, magenta, and yellow in the
  436.      output.  These should not normally need to be adjusted very much;
  437.      even very small adjustments can go quite a long way to restoring
  438.      color balance.
  439.  
  440. _Saturation_
  441.      (0-9.0, default 1.0) Adjust the color brilliance (saturation) of
  442.      the output.  Saturation of 0 means pure gray scale, with no color.
  443.      Saturation of 9.0 will make just about anything but pure grays
  444.      brilliantly colored.
  445.  
  446. _Density_
  447.      (0.1-2.0, default 1.0) Adjust the density (amount of ink) in the
  448.      print.  The density is automatically corrected for the particular
  449.      printer, resolution, and in some cases paper choices.  If solid
  450.      black in the input is not solid in the print, the density needs to
  451.      be increased; if there is excessive ink bleed-through and muddy
  452.      dark colors, the density should be decreased.
  453.  
  454.      *Note*: the density will not increase beyond a certain amount no
  455.      matter what the slider is set to.
  456.  
  457. _Gamma_
  458.      (0.1-4.0, default 1.0) Adjust the output gamma.  The gamma value is
  459.      automatically corrected for the choice of printer; this is used if
  460.      you believe the automatic setting is incorrect.
  461.  
  462. Dither Algorithm
  463. ................
  464.  
  465.    There is also a selection box for the dither algorithm to be used in
  466. the pop-up dialog.  There are currently seven choices:
  467.  
  468. _Adaptive Hybrid_
  469.      Adaptive Hybrid usually yields the best output quality; it chooses
  470.      a modified Floyd-Steinberg error diffusion algorithm or ordered
  471.      dithering depending upon the image characteristics.
  472.  
  473. _Ordered_
  474.      Ordered uses a pure ordered dither.  It generally yields excellent
  475.      quality for simple black and white or four color printers without
  476.      variable drop size or drop modulation; it is not recommended if
  477.      high quality is desired on six color printers.  It is considerably
  478.      faster than Adaptive Hybrid.
  479.  
  480. _Fast_
  481.      Fast also uses a pure ordered dither, but uses a very simple black
  482.      model and makes no attempt to handle multi-level (6-color,
  483.      variable drop size, or drop modulation) at all cleanly.  It is
  484.      substantially faster than Ordered dither.  The quality tends to be
  485.      quite poor except on simple four color printers.  On three color
  486.      printers, quality is probably competitive with anything else.
  487.  
  488. _Very Fast_
  489.      Very Fast is similar to Fast, except that it uses a very simple
  490.      dither matrix that can be looked up much more quickly than the
  491.      matrix used in the Fast dither.  For simple pure black and white
  492.      images dominated by horizontal and vertical lines, this may
  493.      actually yield the best results; for other types of image, the
  494.      quality will be poor.
  495.  
  496. _Adaptive Random_
  497.      Adaptive Random is similar to Adaptive Hybrid, except that the
  498.      modifications to the Floyd-Steinberg algorithm are slightly
  499.      different.  This is slower than Adaptive Hybrid on most systems.
  500.      For some images the quality may be better than Adaptive Hybrid,
  501.      but generally Adaptive Hybrid should yield slightly superior
  502.      images.
  503.  
  504. _Hybrid Floyd-Steinberg_
  505.      Hybrid Floyd-Steinberg uses the modified Floyd-Steinberg algorithm
  506.      of Adaptive Hybrid on the entire image.  Generally, the results
  507.      are poor in pale regions.
  508.  
  509. _Random Floyd-Steinberg_
  510.      Random Floyd-Steinberg uses the modified Floyd-Steinberg algorithm
  511.      of Adaptive Random on the entire image.  Generally, the results
  512.      are poor in pale regions.
  513.  
  514. Action Buttons
  515. --------------
  516.  
  517.    The last pane contains four action buttons:
  518.  
  519. _Print and Save Settings_
  520.      Immediately print the image (or, if the File printer is chosen,
  521.      display a file selection window to pick the output file), and save
  522.      all current settings for all printers.
  523.  
  524. _Save Settings_
  525.      Immediately save the settings, and continue working in the Print
  526.      plugin.
  527.  
  528. _Print_
  529.      Immediately print the image (or, if the `File' printer is chosen,
  530.      display a file selection window to pick the output file), but do
  531.      not save settings.
  532.  
  533. _Cancel_
  534.      Immediately quit without saving settings or printing.
  535.  
  536.    ---------- Footnotes ----------
  537.  
  538.    (1) `http://www.gimp.org'
  539.  
  540.    (2) The output resolution of the plugin.
  541.  
  542.    (3) For Postscript printers.
  543.  
  544.    (4) Again, that's relative to the paper corner, not the printable
  545. area, which is usually smaller.
  546.  
  547. 
  548. File: gimpprint.info,  Node: Ghostscript,  Next: CUPS,  Prev: The GIMP plugin,  Up: Programs
  549.  
  550. Ghostscript driver
  551. ==================
  552.  
  553. 
  554. File: gimpprint.info,  Node: CUPS,  Prev: Ghostscript,  Up: Programs
  555.  
  556. CUPS driver
  557. ===========
  558.  
  559. 
  560. File: gimpprint.info,  Node: Problems,  Next: Appendices,  Prev: Programs,  Up: Top
  561.  
  562. Reporting Bugs
  563. **************
  564.  
  565.    If you find a bug in GIMP-Print or have any suggestions for
  566. modification or improvement, please send electronic mail to the
  567. GIMP-Print bug reporting address (1).  Include the version number,
  568. which you can find by running `gimpprint-config --version'.  Also
  569. include in your message the output that the program produced and the
  570. output you expected, if applicable, otherwise the best description of
  571. the problem that you can provide.
  572.  
  573.    If you have other questions, comments or suggestions about
  574. GIMP-Print, contact the developers via electronic mail to the
  575. GIMP-Print mailing list (2).  They will try to help you out, although
  576. they may not have time to fix your problems.
  577.  
  578.    ---------- Footnotes ----------
  579.  
  580.    (1) <gimp-print-devel@lists.sourceforge.net>
  581.  
  582.    (2) <gimp-print-devel@lists.sourceforge.net>
  583.  
  584. 
  585. File: gimpprint.info,  Node: Appendices,  Next: Data Type and Variable Index,  Prev: Problems,  Up: Top
  586.  
  587. Appendices
  588. **********
  589.  
  590. * Menu:
  591.  
  592. * Dithering::                   Dither algorithms.
  593. * Weaving::                     Weaving algorithms.
  594. * ESC/P2::                      Epson ESC/P2 printer control language.
  595. * New Printer::                 Adding a new printer to libgimpprint.
  596.  
  597. 
  598. File: gimpprint.info,  Node: Dithering,  Next: Weaving,  Prev: Appendices,  Up: Appendices
  599.  
  600. Dithering
  601. *********
  602.  
  603.    The dithering code in `print-dither.c' attempts to reproduce various
  604. shades of gray (or all colors) from only a few different inks (black,
  605. cyan, magenta, yellow, and sometimes light cyan and light magenta).
  606. The dots can't vary in darkness or size (except for certain special
  607. printers), and so we need to lay down a certain fraction of dots to
  608. represent each distinct level.
  609.  
  610.    This sounds straightforward; in practice, it isn't.  Completely
  611. random distribution of dots (simple probabilistic dithering) would
  612. create grainy clumps and light spots.  The smoothest pattern results
  613. from an equidistant spacing of dots.  Approximating this requires
  614. sophisticated algorithms.  We have two dithering algorithms, an ordered
  615. dither algorithm that uses a grid (matrix) to decide whether to print,
  616. and a modified Floyd-Steinberg error diffusion algorithm that uses a
  617. grid in a slightly different way.
  618.  
  619.    We currently have three dithering functions:
  620.  
  621.   1. `dither_fastblack' produces pure black or white from a pre-dithered
  622.      input.  This is used for two purposes: for printing pure black and
  623.      white very quickly (e. g. text), and for printing pre-screened
  624.      monochrome output that was rasterized externally.
  625.  
  626.   2. `dither_black' produces black from grayscale input.  The new
  627.      dither_black can produce either a single or multiple levels of
  628.      black, for printers supporting variable dot size.
  629.  
  630.   3. `dither_cmyk' produces 3, 4, 5, 6, or 7 color output (CMY, CMYK,
  631.      CcMmYK, CcMmYy, CcMmYyK, or any variants).  The new routine can
  632.      handle single or multiple levels of each color.
  633.  
  634.    There is a choice of dithering algorithms.  Four of them are based
  635. on a basic error diffusion, with a few tweaks of my own.  The other one
  636. is `ordered'.  However, they all share the basic operation in common.
  637. First, the algorithm picks what kind of dot (if there are multiple dot
  638. sizes and/or tones that may be picked) is the candidate to be printed.
  639. This decision is made based on the darkness at the point being dithered.
  640. Then, it decides whether the dot will be printed at all.  What this is
  641. based on depends upon which algorithm family we use.  This is all
  642. described in more detail below.
  643.  
  644.    Ordered dithering works by comparing the value at a given point with
  645. the value of a tiled matrix.  If the value at the point is greater than
  646. the value in the matrix, the dot is printed.  The matrix should consist
  647. of a set of evenly spaced points between 0 and the upper limit.  The
  648. choice of matrix is very important for print quality.  A good dither
  649. matrix will emphasize high frequency components, which distributes dots
  650. evenly with a minimum of clumping.  The matrices used here are all
  651. simple matrices that are expanded recursively to create larger matrices
  652. with the same kind of even point distribution.  This is described below.
  653.  
  654.    Note that it is important to use different matrices for the two
  655. sub-operations, because otherwise the choice about whether to print and
  656. the choice of dot size will be correlated.  The usual result is that the
  657. print is either too dark or too light, but there can be other problems.
  658.  
  659.    Ordered dithering works quite well on single dot size, four color
  660. printers.  It has not been well tested on four color, variable dot size
  661. printers.  It should be avoided on six color printers.
  662.  
  663.    Error diffusion works by taking the output error at a given pixel and
  664. "diffusing" it into surrounding pixels.  Output error is the difference
  665. between the amount of ink output and the input level at each pixel.
  666. For simple printers, with one or four ink colors and only one dot size,
  667. the amount of ink output is either 65536 (i. e. full output) or 0 (no
  668. output).  The difference between this and the input level is the error.
  669. Normal error diffusion adds part of this error to the adjoining pixels
  670. in the next column and the next row (the algorithm simply scans each
  671. row in turn, never backing up).  The error adds up until it reaches a
  672. threshold (half of the full output level, or 32768), at which point a
  673. dot is output, the output is subtracted from the current value, and the
  674. (now negative) error is diffused similarly.
  675.  
  676.    Error diffusion works quite well in general, but it tends to generate
  677. artifacts which usually appear as worm-like lines or areas of anomalous
  678. density.  I have devised some ways, as described below, of ameliorating
  679. these artifacts.
  680.  
  681.    There are two sub-classes of error diffusion that we use here,
  682. `random' and `hybrid'.  One of the techniques that we use to ameliorate
  683. the artifacts is to use a fuzzy threshold rather than the hard
  684. threshold of half of the output level.  Random error diffusion uses a
  685. pseudo-random number to perturb the threshold, while hybrid error
  686. diffusion uses a matrix.  Hybrid error diffusion worked very poorly in
  687. 3.1.3, and I couldn't figure out why until I found a bug.  It now works
  688. very well.
  689.  
  690.    There is one additional variant (on both sub-classes), called
  691. `adaptive hybrid' and `adaptive random'.  The adaptive variant takes
  692. advantage of the fact that the patterns that ordered dithering create
  693. are less visible at very low densities, while the artifacts created by
  694. error diffusion are more objectionable at low densities.  At low
  695. densities, therefore, it uses ordered dithering; at higher densities it
  696. uses error diffusion.
  697.  
  698.    Handling multiple output levels makes life a bit more complicated.
  699. In principle, it shouldn't be much harder: simply figure out what the
  700. ratio between the available output levels is and have multiple
  701. thresholds.  In practice, getting these right involves a lot of trial
  702. and error.  The other thing that's important is to maximize the number
  703. of dots that have some ink.  This will reduce the amount of speckling.
  704. More on this later.
  705.  
  706.    The next question: how do we handle black when printing in color?
  707. Black ink is much darker than colored inks.  It's possible to produce
  708. black by adding some mixture of cyan, magenta, and yellow--in
  709. principle.  In practice, the black really isn't very black, and
  710. different inks and different papers will produce different color casts.
  711. However, by using CMY to produce gray, we can output a lot more dots!
  712. This makes for a much smoother image.  What's more, one cyan, one
  713. magenta, and one yellow dot produce less darkness than one black dot,
  714. so we're outputting that many more dots.  Better yet, with 6 or 7 color
  715. printers, we have to output even more light ink dots.  So Epson Stylus
  716. Photo printers can produce really smooth grays--if we do everything
  717. right.  The right idea is to use CMY at lower black levels, and
  718. gradually mix in black as the overall amount of ink increases, so the
  719. black dots don't really become visible within the ink mass.
  720.  
  721.    Variable dot sizes are handled by dividing the range between 0 and
  722. 65536 into segments.  Each segment can either represent a range in
  723. which all of one kind of ink (color and/or dot size) is used, with
  724. varying amounts of ink, or a transition region between inks, in which
  725. equal numbers of dots are printed but the amount of each ink will be
  726. adjusted throughout the range.  Each range is represented by four
  727. numbers:
  728.  
  729.   1. bottom of the range
  730.  
  731.   2. top of the range
  732.  
  733.   3. value of the lighter ink
  734.  
  735.   4. value of the darker ink
  736.  
  737.    In addition, the bit patterns and which type of ink are also
  738. represented, but they don't affect the actual algorithm.
  739.  
  740.    As mentioned above, the basic algorithm is the same whether we use
  741. ordered dither or error diffusion.  We perform the following steps on
  742. each color of each pixel:
  743.  
  744.   1. Compute the value of the particular color we're printing.  This
  745.      isn't usually the pure CMY value; it's adjusted to improve
  746.      saturation and to limit the use of black in light toned regions
  747.      (to avoid speckling).
  748.  
  749.   2. Find the range containing this value.
  750.  
  751.   3. Compute where this value lies within the range.  We scale the
  752.      endpoints between 0 and 65536 for this purpose.  So for example,
  753.      if the bottom of the range is 10,000 and the top of the range is
  754.      20,000, and the value is 12,500, we're 1/4 of the way between the
  755.      bottom and the top of the range, so our scale point is 16384.
  756.  
  757.   4. Compute the "virtual value".  The virtual value is the distance
  758.      between the value of the lighter and the value of the darker ink.
  759.      So if the value of the light ink is 32768 and the dark ink is
  760.      65536, we compute a virtual value scaled appropriately between
  761.      these two values, which is 40960 in this case.
  762.  
  763.   5. Using either error diffusion or ordered dither, the standard
  764.      threshold is 1/2 of the value (20480 in this case).  Using ordered
  765.      dither, we want to compute a value between 0 and 40960 that we
  766.      will compare the input value against to decide whether to print.
  767.      Using pure error diffusion, we would compare the accumulated error
  768.      against 20480 to decide whether to print.  In practice, we use the
  769.      same matrix method to decide whether to print.  The correct amount
  770.      of ink will be printed this way, but we minimize the squiggly
  771.      lines characteristic of error diffusion by dithering the threshold
  772.      in this fashion.  A future enhancement will allow us to control
  773.      the amount of dithering applied to the threshold.
  774.  
  775.    The matrices were generated by Thomas Tonino <<ttonino@bio.vu.nl>>
  776. with an algorithm of his devising.  The algorithm is designed to
  777. maximize the spacing between dots at any given density by searching the
  778. matrix for holes and placing a dot in the largest available hole.  It
  779. requires careful selection of initial points to achieve good results,
  780. and is very time consuming.  For best results, a different matrix must
  781. be used for modes with 2:1 aspect ratio (e.g. 1440x720) than for 1:1
  782. (e. g. 720x720).  It is essential with any of these matrices that every
  783. point be used.  Skipping points generates low-frequency noise.
  784.  
  785.    It's essential to use different matrices for deciding whether to
  786. print and for deciding what color (dark or light) to print.  This
  787. should be obvious; the decision about whether to print at all should be
  788. as independent as possible from the decision about what color to print,
  789. because any bias will result in excess light or dark ink being printed,
  790. shifting the tonal balance.  We actually use the same matrices, but we
  791. shift them vertically and horizontally.  Assuming that the matrices are
  792. not self-correlated, this will yield good results.
  793.  
  794.    The ranges are computed from a list of ink values (between 0 and 1
  795. for each possible combination of dot size and ink tone, where the value
  796. represents the darkness of the ink) and the desired maximum density of
  797. the ink.  This is done in dither_set_ranges, and needs more
  798. documentation.
  799.  
  800.    I stated earlier that I've tweaked the basic error diffusion
  801. algorithm.  Here's what I've done to improve it:
  802.  
  803.   1. We use a variable threshold to decide when to print, as discussed
  804.      above.  This does two things for us: it reduces the slightly
  805.      squiggly diagonal lines that are the mark of error diffusion; and
  806.      it allows us to lay down some ink even in very light areas near
  807.      the edge of the image.  The squiggly lines that error diffusion
  808.      algorithms tend to generate are caused by the gradual accumulation
  809.      of error.  This error is partially added horizontally and
  810.      partially vertically.  The horizontal accumulation results in a
  811.      dot eventually being printed.  The vertical accumulation results
  812.      in a dot getting laid down in roughly the same horizontal position
  813.      in the next row.  The diagonal squigglies result from the error
  814.      being added to pixels one forward and one below the current pixel;
  815.      these lines slope from the top right to the bottom left of the
  816.      image.
  817.  
  818.      Error diffusion also results in pale areas being completely white
  819.      near the top left of the image (the origin of the printing
  820.      coordinates).  This is because enough error has to accumulate for
  821.      anything at all to get printed.  In very pale areas it takes quite
  822.      a long time to build up anything printable at all; this results in
  823.      the bare spots.
  824.  
  825.      Randomizing the threshold somewhat breaks up the diagonals to some
  826.      degree by randomizing the exact location that the accumulated
  827.      output crosses the threshold.  It reduces the false white areas by
  828.      allowing some dots to be printed even when the accumulated output
  829.      level is very low.  It doesn't result in excess ink because the
  830.      full output level is still subtracted and diffused.
  831.  
  832.      Excessive randomization leads to blobs at high densities.
  833.      Therefore, as the density increases, the degree of randomization
  834.      decreases.
  835.  
  836.   2. Alternating scan direction between rows (first row is scanned left
  837.      to right, second is scanned right to left, and so on).  This also
  838.      helps break up white areas, and it also seems to break up
  839.      squigglies a bit.  Furthermore, it eliminates directional biases
  840.      in the horizontal direction.  This isn't necessary for ordered
  841.      dither, but it doesn't hurt either.
  842.  
  843.   3. Diffusing the error into more pixels.  Instead of diffusing the
  844.      entire error into (X+1, Y) and (X, Y+1), we diffuse it into (X+1,
  845.      Y), (X+K, Y+1), (X, Y+1), (X-K, Y+1) where K depends upon the
  846.      output level (it never exceeds about 10 dots, and is greater at
  847.      higher output levels).  This really reduces squigglies and
  848.      graininess.  The amount of this spread can be controlled; for line
  849.      art, it should be less than for photographs (of course, line art
  850.      doesn't usually contain much light color, but the *error* value
  851.      can be small in places!)  In addition to requiring more
  852.      computation, a wide ink spread results in patterning at high dot
  853.      densities (note that the dot density can be high even in fairly
  854.      pale regions if multiple dot sizes are in use).
  855.  
  856.   4. Don't lay down any colored ink if we're laying down black ink.
  857.      There's no point; the colored ink won't show.  We still pretend
  858.      that we did for purposes of error diffusion (otherwise excessive
  859.      error will build up, and will take a long time to clear, resulting
  860.      in heavy bleeding of ink into surrounding areas, which is very
  861.      ugly indeed), but we don't bother wasting the ink.  How well this
  862.      will do with variable dot size remains to be seen.
  863.  
  864.   5. Oversampling.  This is how to print 1440x720 with Epson Stylus
  865.      printers.  Printing full density at 1440x720 will result in excess
  866.      ink being laid down.  The trick is to print only every other dot.
  867.      We still compute the error as though we printed every dot.  It
  868.      turns out that randomizing which dots are printed results in very
  869.      speckled output.  This can be taken too far; oversampling at
  870.      1440x1440 or 1440x2880 virtual resolution results in other
  871.      problems.  However, at present 1440x1440 (which is more accurately
  872.      called "1440x720 enhanced", as the Epson printers cannot print
  873.      1440 rows per inch) does quite well, although it's slow.
  874.  
  875.    What about multiple output levels?  For 6 and 7 color printers,
  876. simply using different threshold levels has a problem: the pale inks
  877. have trouble being seen when a lot of darker ink is being printed.  So
  878. rather than just using the output level of the particular color to
  879. decide which ink to print, we look at the total density (sum of all
  880. output levels).  If the density's high enough, we prefer to use the
  881. dark ink.  Speckling is less visible when there's a lot of ink, anyway.
  882. I haven't yet figured out what to do for multiple levels of one color.
  883.  
  884.    You'll note that I haven't quoted a single source on color or
  885. printing theory.  I simply did all of this empirically.
  886.  
  887.    There are various other tricks to reduce speckling.  One that I've
  888. seen is to reduce the amount of ink printed in regions where one color
  889. (particularly cyan, which is perceived as the darkest) is very pale.
  890. This does reduce speckling all right, but it also results in strange
  891. tonal curves and weird (to my eye) colors.
  892.  
  893.    Before any dither routine is used, `init_dither()' must be called.
  894. This takes three arguments: the input width (number of pixels in the
  895. input), the output width (number of pixels in the output), and a
  896. `vars_t' structure containing the parameters for the print job.
  897.  
  898.    `init_dither()' returns a pointer to an opaque object representing
  899. the dither.  This object is passed as the first argument to all of the
  900. dither-related routines.
  901.  
  902.    After a page is fully dithered, `free_dither()' must be called to
  903. free the dither object and perform any cleanup.  In the future, this may
  904. do more (such as flush output).  This arrangement permits using these
  905. routines with programs that create multiple output pages, such as
  906. GhostScript.
  907.  
  908.    The dithering routines themselves have a number of control knobs that
  909. control internal aspects of the dithering process.  These knobs are
  910. accessible via a number of functions that can be called after
  911. `init_dither()'.
  912.  
  913.    * `dither_set_density()' takes a double between 0 and 1 representing
  914.      the desired ink density for printing solid colors.  This is used
  915.      in a number of places in the dithering routine to make decisions.
  916.  
  917.    * `dither_set_black_density()' takes a double between 0 and 1
  918.      representing the desired ink density for printing black ink in
  919.      color printing.  This is used to balance black against color ink.
  920.      By default, this is equal to the density set by
  921.      `dither_set_density()'.  By setting it higher, more black ink will
  922.      be printed.  For example, if the base density is .4 and the black
  923.      density is .8, twice as much black ink will be printed as would
  924.      otherwise be called for.
  925.  
  926.      This is not used when printing in monochrome.  When printing
  927.      monochrome, the base density (`dither_set_density') should be
  928.      adjusted appropriately.
  929.  
  930.    * `dither_set_ink_budget()' takes an unsigned number representing the
  931.      most ink that may be deposited at a given point.  This number is
  932.      arbitrary; the limit is computed by summing the size of each ink
  933.      dot, which is supplied as a parameter in `dither_set_X_ranges'.
  934.      By default, there is no limit.
  935.  
  936.    * `dither_set_black_lower()' takes a double that should be between 0
  937.      and 1 that represents the lowest density level at which black ink
  938.      will start to mix in with colored ink to generate grays.  The
  939.      lower this is, the less density is required to use black ink.
  940.      Setting this too low will result in speckling from black dots,
  941.      particularly on 6 and 7 color printers.  Setting this too high
  942.      will make it hard to get satisfactory black or may result in sharp
  943.      transition between blended colors and black.  Default: 0.0468.
  944.  
  945.      It is important to note that since the density scale is never
  946.      linear (and since this value is adjusted via other things
  947.      happening during the dithering process) that this does not mean
  948.      that 95% gray will use any black ink.  At this setting, there will
  949.      be no black ink used until about 50% gray.
  950.  
  951.      This only applies to color mode.
  952.  
  953.      This value should be set lower for printers capable of variable dot
  954.      size, since more dots can be laid down close to each other.
  955.  
  956.    * `dither_set_black_upper()' takes a double that should be between 0
  957.      and 1 that represents the highest density level at which colored
  958.      inks will be mixed to create gray.  Setting this too low will
  959.      result in speckly dark grays because there is not enough ink to
  960.      fill all the holes, or sharp transition between blended colors and
  961.      black if it is too close to the value of dither_set_black_upper().
  962.      Setting this too high will result in poor black and dark tone
  963.      quality.  Default: 0.5.  This results in 10% and darker grays
  964.      being printed with essentially all black.
  965.  
  966.      This only applies to color mode.
  967.  
  968.    * `dither_set_black_levels()' takes three doubles that represent the
  969.      amount of cyan, magenta, and yellow respectively that are blended
  970.      to create gray.  The defaults are 1.0 for each, which is probably
  971.      too low for most printers.  These values are adjusted to create a
  972.      good gray balance.  Setting these too low will result in pale
  973.      light and midtone grays, with a sharp transition to darker tones
  974.      as black mixes in.  Setting them too high will result in overly
  975.      dark grays and use of too much ink, possibly creating
  976.      bleed-through.
  977.  
  978.      This only applies to color mode.
  979.  
  980.    * `dither_set_randomizers()' takes four integer values representing
  981.      the degree of randomness used for cyan, magenta, yellow, and black.
  982.      This is used to allow some printing to take place in pale areas.
  983.      Zero is the most random; greater than 8 or so gives very little
  984.      randomness at all.  Defaults are 0 for cyan, magenta, and yellow,
  985.      and 4 for black.  Setting the value for black too low will result
  986.      in black speckling in pale areas.  Setting values too high will
  987.      result in pale areas getting no ink at all.
  988.  
  989.      This currently only applies to single dot size in color and black.
  990.      It should be extended to operate in variable dot size mode,
  991.      although actually applying it correctly will be tricky.
  992.  
  993.    * `dither_set_ink_darkness()' takes three doubles representing the
  994.      contribution to perceived darkness of cyan, magenta, and yellow.
  995.      This is used to help decide when to switch between light and dark
  996.      inks in 6 and 7 color printers (with light cyan, light magenta,
  997.      and possibly light yellow).  Setting these too low will result in
  998.      too much light ink being laid down, creating flat spots in the
  999.      darkness curves and bleed-through.  Setting them too high will
  1000.      result in dark ink being used in pale areas, creating speckle.
  1001.      The defaults are .4 for cyan, .3 for magenta, and .2 for yellow.
  1002.      Dark cyan will show against yellow much more than dark magenta
  1003.      will show against cyan, since the cyan appears much darker than
  1004.      the yellow.
  1005.  
  1006.    * `dither_set_light_inks()' takes three doubles between 0 and 1
  1007.      representing the ratio in darkness between the light and dark
  1008.      versions of the inks.  Setting these too low will result in too
  1009.      much dark ink being used in pale areas, creating speckling, while
  1010.      setting them too high will result in very smooth texture but too
  1011.      much use of light ink, resulting in flat spots in the density
  1012.      curves and ink bleed-through.  There are no defaults.  Any light
  1013.      ink specified as zero indicates that there is no light ink for
  1014.      that color.
  1015.  
  1016.      This only applies to 6 and 7 color printers in single dot size
  1017.      color mode, and only to those inks which have light versions
  1018.      (usually cyan and magenta).
  1019.  
  1020.    * `dither_set_ink_spread()' takes a small integer representing the
  1021.      amount of ink spread in the dither.  Larger numbers mean less
  1022.      spread.  Larger values are appropriate for line art and solid
  1023.      tones; they will yield sharper transitions but more dither
  1024.      artifacts.  Smaller values are more appropriate for photos.  They
  1025.      will reduce resolution and sharpness but reduce dither artifacts
  1026.      up to a point.  A value of 16 or higher implies minimum ink spread
  1027.      at any resolution no matter what the overdensity.  A value of 14
  1028.      is typical for photos on single dot size, 6 color printers.  For 4
  1029.      color printers, subtract 1 (more spread; the dots are farther
  1030.      apart).  For variable dot size printers, add 1 (more small dots
  1031.      are printed; less spread is desirable).
  1032.  
  1033.    * `dither_set_adaptive_divisor()' takes a float representing the
  1034.      transition point between error diffusion and ordered dither if
  1035.      adaptive dithering is used.  The float is a fraction of the
  1036.      printing density.  For example, if you wish the transition to be
  1037.      at 1/4 of the maximum density (which works well on simple 4-color
  1038.      printers), you would pass .25 here.  With six colors and/or with
  1039.      multiple dot sizes, the values should be set lower.
  1040.  
  1041.    * `dither_set_transition()' takes a float representing the exponent
  1042.      of the transition curve between light and dark inks/dot sizes.  A
  1043.      value less than 1 (typical when using error diffusion) mixes in
  1044.      less dark ink/small dots at lower ends of the range, to reduce
  1045.      speckling.  When using ordered dithering, this must be set to 1.
  1046.  
  1047.    * `dither_set_X_ranges_simple' (X=`c', `m', `y', or `k') describes
  1048.      the ink choices available for each color.  This is useful in
  1049.      typical cases where a four color printer with variable dot sizes
  1050.      is in use.  It is passed an array of doubles between (0, 1]
  1051.      representing the relative darkness of each dot size.  The dot
  1052.      sizes are assigned bit patterns (and ink quantities, see
  1053.      `dither_set_ink_budget()' above) from 1 to the number of levels.
  1054.      This also requires a density, which is the desired density for this
  1055.      color.  This density need not equal the density specified in
  1056.      `dither_set_density()'.  Setting it lower will tend to print more
  1057.      dark ink (because the curves are calculated for this color
  1058.      assuming a lower density than is actually supplied).
  1059.  
  1060.    * `dither_set_X_ranges' (X=`c', `m', `y', or `k') describes in a
  1061.      more general way the ink choices available for each color.  For
  1062.      each possible ink choice, a bit pattern, dot size, value (i. e.
  1063.      relative darkness), and whether the ink is the dark or light
  1064.      variant ink is specified.
  1065.  
  1066.    --Robert Krawitz <<rlk@alum.mit.edu>> May 8, 2000
  1067.  
  1068. 
  1069. File: gimpprint.info,  Node: Weaving,  Next: ESC/P2,  Prev: Dithering,  Up: Appendices
  1070.  
  1071. Weaving for inkjet printers
  1072. ***************************
  1073.  
  1074. by Charles Briscoe-Smith and Robert Krawitz.
  1075.  
  1076. * Menu:
  1077.  
  1078. * Weaving introduction::        Just what is weaving?
  1079. * Weaving algorithms::          How to weave.
  1080.  
  1081.